package com.bank.entity;

public class DepositType {
    private int savingID;      // 存款类型ID（主键）
    private String savingName; // 存款类型名称
    private String descrip;   // 存款类型描述

    // 添加无参构造函数
    public DepositType() {
        // 空构造函数
    }
    // 4参数构造函数
    public DepositType(int savingID, String savingName, String descrip) {
        this.savingID = savingID;
        this.savingName = savingName;
        this.descrip = descrip;

    }

    // Getters
    public int getSavingID() {
        return savingID;
    }

    public String getSavingName() {
        return savingName;
    }


    // 修复描述字段的getter方法名
    public String getDescript() { // 保持原方法名不变
        return descrip;
    }



    // Setters
    public void setSavingID(int savingID) {
        this.savingID = savingID;
    }

    public void setSavingName(String savingName) {
        this.savingName = savingName;
    }

    public void setDescript(String descript) {
        this.descrip = descript;
    }




    // 获取摘要信息
    public String getSummary() {
        return savingName + " - " + descrip;
    }


    // 修复toString()方法中的拼写错误
    @Override
    public String toString() {
        return savingName + " (" + savingID + ")";
    }
    // 预定义存款类型常量（使用3参数构造函数）
    public static final DepositType CURRENT = new DepositType(1, "活期", "按存款日结算");
    public static final DepositType FIXED_1Y = new DepositType(2, "定期一年", "存款期是1年");
    public static final DepositType FIXED_2Y = new DepositType(3, "定期二年", "存款期是2年");
    public static final DepositType FIXED_3Y = new DepositType(4, "定期三年", "存款期是3年");
    public static final DepositType FLEXIBLE = new DepositType(5, "定活两便", "灵活存取");
    public static final DepositType INSTALLMENT_1Y = new DepositType(6, "零存整取一年", "每月存款，一年期");
    public static final DepositType INSTALLMENT_2Y = new DepositType(7, "零存整取二年", "每月存款，二年期");
    public static final DepositType INSTALLMENT_3Y = new DepositType(8, "零存整取三年", "每月存款，三年期");

    // 获取所有预定义类型
    public static DepositType[] getAllTypes() {
        return new DepositType[]{
                CURRENT, FIXED_1Y, FIXED_2Y, FIXED_3Y,
                FLEXIBLE, INSTALLMENT_1Y, INSTALLMENT_2Y, INSTALLMENT_3Y
        };
    }

    // 根据ID获取类型
    public static DepositType getById(int id) {
        switch (id) {
            case 1: return CURRENT;
            case 2: return FIXED_1Y;
            case 3: return FIXED_2Y;
            case 4: return FIXED_3Y;
            case 5: return FLEXIBLE;
            case 6: return INSTALLMENT_1Y;
            case 7: return INSTALLMENT_2Y;
            case 8: return INSTALLMENT_3Y;
            default: return null;
        }
    }
}